package com.qying.sofa.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.util.Objects;

/**
 * @Author 秦扬
 * @Date 2021/11/9 14:31
 */
public class EsClient {

    private static RestHighLevelClient client;


    public static RestHighLevelClient getClient() {

        if (Objects.isNull(client)) {
            synchronized(EsClient.class) {
                if (Objects.isNull(client)){
                    client = new RestHighLevelClient(
                            RestClient.builder(
                                    new HttpHost("localhost", 19201, "http"),
                                    new HttpHost("localhost", 19202, "http")));
                }
            }
        }

        return client;
    }

}
